home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- #include <dos/dos.h>
- #include <proto/dos.h>
- #include <proto/exec.h>
- #include <exec/execbase.h>
- #include <exec/libraries.h>
- #include <exec/memory.h>
- #include <pragmas/dos_pragmas.h>
- #include <string.h>
-
- #define DIROFFSET 0x410
- #define FILEOFFSET 0x1600
- #define BLOCKSIZE 0x10
- #define MAXNUMFILES 200
- #define MAXFILESIZE 0x14000
- #define MAXNAMELENGTH 0x10
-
- struct dirstructure {
- char name[MAXNAMELENGTH];
- int length;
- } dir[MAXNUMFILES];
-
-
- BPTR oldlock,newlock;
-
- FILE *fp=NULL,*fo=NULL;
- unsigned char temp[BLOCKSIZE+1],*temp2=NULL;
-
- void CloseAll(char *mess)
-
- {
-
- if (fp) fclose(fp);
- if (temp2) free(temp2);
-
- if (newlock)
- {
- CurrentDir(oldlock);
- UnLock(newlock);
- }
-
- if (mess)
- {printf("** %s\n",mess);exit(1);}
- else exit(0);
-
- }
-
-
- void main (int argc, char *argv[])
- {
- int count,count2;
-
- printf("Oh No More Lemmings NDOS version file ripper by K. Krellwitz\nadapted by JF Fabre.\n");
-
- if (argc<3)
- {
- printf ("Usage: ripono <filename> <dest-dir>\n");
- exit(1);
- }
-
-
- if((fp=fopen(argv[1],"r"))==NULL)
- {
- printf ("Cannot open file %s\n",argv[1]);
- CloseAll("");
- }
-
- /* Try to lock the specified directory */
-
- newlock = Lock(argv[2],ACCESS_READ);
- if (!newlock) CloseAll("Couldn't lock destination directory");
- oldlock = CurrentDir(newlock);
-
- temp2=(char *)malloc(MAXFILESIZE);
-
- if (!temp2)
- {
- CloseAll("Not enough memory\n");
- }
-
- fseek(fp,DIROFFSET,SEEK_SET);
- fread(temp,BLOCKSIZE,1,fp);
- count=0;
-
- while(temp[0]!=0xff)
- {
- for(count2=0;temp[count2]!=0;count2++)
- dir[count].name[count2]=temp[count2];
- dir[count].name[count2]='\0';
- dir[count].length=temp[BLOCKSIZE-3]*0x10000+
- temp[BLOCKSIZE-2]*0x100+temp[BLOCKSIZE-1];
- fread(temp,BLOCKSIZE,1,fp);
- if(temp[0]!=0xff)
- count++;
- }
- fseek(fp,FILEOFFSET,SEEK_SET);
- for(count2=0;count2<=count;count2++)
- {
- fread(temp2,dir[count2].length,1,fp);
- if((fo=fopen(dir[count2].name,"wb"))==NULL)
- {
- CloseAll("Can't create destination file(s)");
- }
- fwrite(temp2,dir[count2].length,1,fo);
- fclose(fo);
- printf("Created %s %x\n",dir[count2].name,dir[count2].length);
- }
-
- printf("Done.\n");
- CloseAll(NULL);
-
- }
-